package demo1;

public class Test1 {
    public static void main(String[] args) {
        System.out.println(countSegments("1, 2, 3"));

    }
    public static int countSegments(String s) {
        int len = s.length() ;
        int count = 0 ;
        for(int i = 0 ; i < len;i++){
            if(s.charAt(i) != ' '){
                count++ ;
                while(i < len && s.charAt(i)!= ' ' ){
                    i ++ ;
                }
            }
        }
        return count ;
    }

}
